/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package es.us.isa.jdbl.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.SecondaryTables;
import javax.persistence.Table;

@Entity
@SecondaryTables({
	@SecondaryTable(name="content_type_contract", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
	@SecondaryTable(name="content_field_acronym", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
	@SecondaryTable(name="content_field_amount", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
	@SecondaryTable(name="content_field_amount_detail", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
	@SecondaryTable(name="content_field_startdate", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
	@SecondaryTable(name="content_field_end_date", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
	@SecondaryTable(name="content_field_idi", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")})
})
@DiscriminatorValue("contract")
public class Contract extends AbstractNode{
	@Column(name="field_typeofcontract_value", columnDefinition="LONGTEXT", table="content_type_contract")
	private String typeContract;
	@Column(name="field_acronym_value", table="content_field_acronym")
	private String acronym;
	@Column(name="field_amount_value", table="content_field_amount")
	private String amount;
	@Column(name="field_amount_detail_value", table="content_field_amount_detail")
	private String amountDetail;
	@Column(name="field_startdate_value", table="content_field_startdate")
	private String startDate;
	@Column(name="field_end_date_value", table="content_field_end_date")
	private String endDate;
	@Column(name="field_idi_value", table="content_field_idi")
	private Boolean idi;
	@ManyToOne
	@JoinTable(name="content_field_organization", catalog = "webisa",
			joinColumns=@JoinColumn(name="nid"),
			inverseJoinColumns=@JoinColumn(name="field_organization_nid"))
	private Organization financialOrganization;
	@OneToMany
	@JoinTable(name="content_field_organization_participating", catalog = "webisa",
			joinColumns=@JoinColumn(name="nid"),
			inverseJoinColumns=@JoinColumn(name="field_organization_participating_nid"))
	private List<Organization> participatingOrganization;
	@OneToMany
	@JoinTable(name="content_field_projects", catalog = "webisa",
			joinColumns=@JoinColumn(name="nid"),
			inverseJoinColumns=@JoinColumn(name="field_projects_nid"))
	private List<Project> projects;
	
	
	public Contract(){
		
	}
	
	public Contract(String title, String typeContract){
		this.setTypeContract(typeContract);
	}

	public void setTypeContract(String typeContract) {
		this.typeContract = typeContract;
	}

	public String getTypeContract() {
		return typeContract;
	}

	public void setAcronym(String acronym) {
		this.acronym = acronym;
	}

	public String getAcronym() {
		return acronym;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}

	public String getAmount() {
		return amount;
	}

	public void setAmountDetail(String amountDetail) {
		this.amountDetail = amountDetail;
	}

	public String getAmountDetail() {
		return amountDetail;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setIdi(boolean idi) {
		this.idi = idi;
	}

	public boolean isIdi() {
		return idi;
	}

	public void setFinancialOrganization(Organization financialOrganization) {
		this.financialOrganization = financialOrganization;
	}

	public Organization getFinancialOrganization() {
		return financialOrganization;
	}

	public void setParticipatingOrganization(
			List<Organization> participatingOrganization) {
		this.participatingOrganization = participatingOrganization;
	}

	public List<Organization> getParticipatingOrganization() {
		return participatingOrganization;
	}

	public void setProjects(List<Project> projects) {
		this.projects = projects;
	}

	public List<Project> getProjects() {
		return projects;
	}
}
